package com.example.myapplication

import android.os.Bundle
import android.util.Log
import android.view.Gravity
import android.view.MotionEvent
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity


class OnePixelActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.e("test", "OnePixel onCreate")
        //设置1像素
        val window = window
        window.setGravity(Gravity.LEFT or Gravity.TOP)
        val params = window.attributes
        params.x = 0
        params.y = 0
        params.height = 1
        params.width = 1
        window.attributes = params
        getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
        )
    }

    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        return super.dispatchTouchEvent(ev)
    }

    override fun onStart() {
        super.onStart()
        Log.e("test", "OnePixel onStart")
    }

    override fun onResume() {
        super.onResume()
        Log.e("test", "OnePixel onResume")
    }

    override fun onPause() {
        super.onPause()
        Log.e("test", "OnePixel onPause")

    }

    override fun onStop() {
        super.onStop()
        Log.e("test", "OnePixel onStop")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.e("test", "OnePixel onDestroy")
    }
}